package com.zl.learning.collection;

import org.junit.Test;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class PredicateTest {
    @Test
    public void test1(){
        Set<String> books = new HashSet<>();
        books.add("轻量级JavaEE企业应用实战");
        books.add("疯狂Java讲义");
        books.add("疯狂IOS讲义");
        books.add("疯狂Ajax讲义");
        books.add("疯狂Android讲义");
        books.removeIf(ele -> ele.length()>10);
        System.out.println(books);
    }

    @Test
    public void test2(){
        Set<String> books = new HashSet<>();
        books.add("轻量级JavaEE企业应用实战");
        books.add("疯狂Java讲义");
        books.add("疯狂IOS讲义");
        books.add("疯狂Ajax讲义");
        books.add("疯狂Android讲义");
        Iterator<String> it = books.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
            it.remove();
        }
        System.out.println(books);
    }
}
